package com.spt.springbootzhsx.service.suggest.Get_Result_7;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultBean implements WritableComparable<ResultBean> {
    private String uid;
    private String mid;
    private int flag;
    //flag 为1 表示数据来源于源数据
    //flag 为0 表示数据来源于第六步结果

    @Override
    public int compareTo(ResultBean o) {
        int i = this.getUid().compareTo(o.getUid());
        //当用户id不相同时
        if (i != 0) {
            return i;
        } else return this.getMid().compareTo(o.getMid());
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(uid);
        dataOutput.writeUTF(mid);
        dataOutput.writeInt(flag);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.uid = dataInput.readUTF();
        this.mid = dataInput.readUTF();
        this.flag = dataInput.readInt();
    }
}
